package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.WorkerOrderStatus;
import com.cloudfun.campusshare.common.constant.WorkerOrderTaskType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * @author : zhangyongjie
 * @version : 1.0
 * @createTime : 2020/5/9 19:37
 * @description :
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "worker_order")
public class WorkerOrderEntity extends BaseEntity{
    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", unique = true, columnDefinition = ("varchar(40) not null comment '主键uuid'"))
    private String id;

    @Column(name = "worker_order_no", unique = true, columnDefinition = ("varchar(32) not null comment '工单任务号'"))
    private String workerOrderNo;

    @Column(name = "task_type", columnDefinition = ("varchar(32) not null comment '任务类型'"))
    @Enumerated(value = EnumType.STRING)
    private WorkerOrderTaskType taskType;

    @Column(name = "merchant_id", columnDefinition = ("varchar(40) not null comment '商家id'"))
    private String merchantId;

    @Column(name = "wash_point_id", columnDefinition = ("varchar(40) default null comment '洗衣点Id'"))
    private String washPointId;

    @Column(name = "wash_point_name", columnDefinition = ("varchar(64) default null comment '洗衣点名称'"))
    private String washPointName;

    @Column(name = "belong_merchant_name", columnDefinition = ("varchar(64) default null comment '所属商家名称'"))
    private String belongMerchantName;

    @Column(name = "submit_time", columnDefinition = ("datetime(0) not null comment '提交时间'"))
    private LocalDateTime submitTime;

    @Column(name = "expire_time", columnDefinition = ("datetime(0) not null comment '过期时间'"))
    private LocalDateTime expireTime;

    @Column(name = "status", columnDefinition = ("varchar(64) default null comment '工单状态'"))
    @Enumerated(EnumType.STRING)
    private WorkerOrderStatus workerOrderStatus;

    @Column(name = "business_id", columnDefinition = ("varchar(40) not null comment '业务id'"))
    private String businessId;

    @JoinColumn(name = "business_id",updatable = false,insertable = false)
    @OneToOne
    private RepairEntity repairEntity;

    @Column(name = "transactor_id", columnDefinition = ("varchar(40) not null comment '当前处理人id'"))
    private String transactorId;

    @Column(name = "transactor_name", columnDefinition = ("varchar(40) not null comment '当前处理人用户名'"))
    private String transactorName;

    @Column(name = "opened_time", columnDefinition = ("varchar(64) not null comment '工单已打开时间'"))
    private String openedTime;

}
